﻿using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
using Comkarl.Restful.Shell.External;
using SampleCommands.Classes;

namespace SampleCommands
{
    /// <summary>
    /// Represents the base class of current project's shell commands.
    /// </summary>
    public abstract class ShellCommandBase : ShellCommand
    {
        public override void Initialize()
        {
            base.Initialize();

            if (Container.Current == null)
            {
                /* Take advantage of overridding this method in order to initialize resources and make them available for the rest of shell commands during
                 * application life-cycle. Remember this method will be executed once: when sandbox starts. */
                Container.Current = ShellUtility.Critical(() => new WindsorContainer(new XmlInterpreter(ResolveDataPath("Container.config"))));
            }
        }
    }
}